<template>
	<view>
		<uni-list>
			<uni-list-item title="头像" :showArrow="true" @click="choseImg">
				<template v-slot:right="">
					<image style="width: 100rpx;height: 100rpx;" :src="userInfo.headPic" mode="widthFix"></image>
				</template>
			</uni-list-item>
			<uni-list-item title="名字" :rightText="userInfo.realName" :showArrow="false"></uni-list-item>
			<uni-list-item title="性别" :rightText="userInfo.sex" :showArrow="false"></uni-list-item>
			<uni-list-item title="手机" :rightText="userInfo.phone" @click="toPage('/pages/user/info/edit-phone?id=' + userInfo.id + '&phone=' + userInfo.phone)"></uni-list-item>
			<uni-list-item title="邮箱" :rightText="userInfo.email" @click="toPage('/pages/user/info/edit-email?id=' + userInfo.id + '&email=' + userInfo.email)"></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
import userService from '../../../api/user.js';
export default {
	data() {
		return {
			userInfo: {}
		};
	},
	onLoad() {
		const that = this;
		that.userInfo = uni.getStorageSync(that.$config.USER_KEY);
		that.getUserInfo()
	},
	methods: {
		getUserInfo: function() {
			const that = this;
			userService.getUserInfo().then(res => {
				if (res.success) {
					that.userInfo = res.data
					//获取之后，放到缓存中
					uni.setStorageSync(that.$config.USER_KEY, that.userInfo);
				}
			});
		},
		//跳转到某一个页面
		toPage: function(page) {
			const that = this;
			uni.navigateTo({
				url: page
			});
		},
		choseImg: function() {
			uni.chooseImage({
				count: 1,
				success: function(res) {
					//上传blob文件流
					console.log(JSON.stringify(res.tempFilePaths));
				}
			});
		},
		choseSex: function() {
			uni.chooseImage({
				count: 1,
				success: function(res) {
					//上传blob文件流
					console.log(JSON.stringify(res.tempFilePaths));
				}
			});
		}
	}
};
</script>

<style></style>
